/*
 * HeapDBFile.h
 *
 *  Created on: Mar 2, 2011
 *      Author: mayank
 */

#ifndef HEAPDBFILE_H_
#define HEAPDBFILE_H_

#include "TwoWayList.h"
#include "Record.h"
#include "Schema.h"
#include "File.h"
#include "Comparison.h"
#include "ComparisonEngine.h"
#include "BigQ.h"
#include "GenericDBFile.h"

#ifndef FTYPE_
#define FTYPE_
typedef enum {heap, sorted, tree} fType;
#endif

//class GenericDBFile;

class HeapDBFile : public GenericDBFile {
private:
	off_t readRecordPointer;
	File* myFile;
	Page* currentGetPage;
	Page* currentPage;
	bool isFileOpen;
	bool loadFlag;
	bool addFlag;
	off_t readPagePointer;
	int addCounter;
	int countGetNext;
public:
	HeapDBFile();
	~HeapDBFile();
	int Create (char *fpath);
	int Open (char *fpath);
	int Close ();

	void Load (Schema &myschema, char *loadpath);

	void MoveFirst ();
	void Add (Record &addme);
	int GetNext (Record &fetchme);
	int GetNext (Record &fetchme, CNF &cnf, Record &literal);
};

#endif /* HEAPDBFILE_H_ */
